package com.woniu.springsecurity.exception;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.woniu.springsecurity.response.ResponseResult;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.rmi.AccessException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler({
            AccessDeniedException.class,
            AuthenticationException.class
    })
    public ResponseResult<Object> handle(Exception e) {
        System.out.println(e.getMessage());

        return null;
    }
}
